package com.xmall.controller.admin;


import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.vo.IssueList;

import com.xmall.bean.table.Issue;
import com.xmall.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/issue")
public class IssueController {

    @Autowired
    IssueService mallService;

    @RequestMapping("list")
    public BaseRespVo selectIssueList(Integer page, Integer limit, String question, String sort, String order){

        IssueList<Issue> lists =  mallService.selectIssueList(page,limit,question,sort,order);
//        System.out.println(lists);
        return BaseRespVo.ok(lists);
    }


    @RequestMapping("create")
    //@RequestBody接受json数据
    public BaseRespVo insertIssue(@RequestBody Issue issue){
        System.out.println(issue);
        Issue issue1 = mallService.insertIssue(issue);
        return BaseRespVo.ok(issue1);
    }

    @RequestMapping("delete")
    //@RequestBody接受json数据
    //可以直接通过对象接受
    public BaseRespVo deleteIssue(@RequestBody Issue issue){

        System.out.println(issue);
        Integer integer = mallService.deleteIssue(issue);
        return BaseRespVo.ok(0);
    }

    @RequestMapping("update")
    public BaseRespVo updateIssue(@RequestBody Issue issue){
        System.out.println(issue);
        Issue issue1 = mallService.updateIssue(issue);
        return BaseRespVo.ok(issue);
    }

}
